
#include	<string.h>
#include	<unistd.h>
#include	<stdlib.h>
#include	<sys/types.h>
#include	<sys/stat.h>
#include	<fcntl.h>

int		main(int ac, char **av)
{
  int		pipefd[2];
  int		error;
  char		buff[512];
  int		len;

  error = pipe(pipefd);
  if (error == -1)
    {
      write(2, "Pipe failed\n", strlen("Pipe failed\n"));
      exit(EXIT_FAILURE);
    }
  error = dup2(pipefd[1], 0);
  if (error == -1)
    {
      write(2, "Dup2 failed\n", strlen("Dup2 failed\n"));
      exit(EXIT_FAILURE);
    }
  error = 0;
  error = dup2(pipefd[0], 1);
  if (error == -1)
    {
      write(2, "Dup2 failed\n", strlen("Dup2 failed\n"));
      exit(EXIT_FAILURE);
    }
  write(0, "timmy\n", 6);
  len = read(pipefd[1], buff, 511);
  if (len == -1)
    {
      write(2, "Read failed\n", strlen("Read failed\n"));
      exit(EXIT_FAILURE);
    }
  buff[len] = '\0';
  puts(buff);
}
